home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Meta.sig < prev    next >
Encoding:
Text File  |  1997-07-22  |  7.3 KB  |  153 lines  |  [TEXT/R*ch]

  1. (* Meta -- functions for use in an interactive Moscow ML session *)
  2.  
  3. val printVal    : 'a -> 'a
  4. val printDepth  : int ref
  5. val printLength : int ref
  6. val installPP   : (ppstream -> 'a -> unit) -> unit
  7.  
  8. val use         : string -> unit
  9. val compile     : string -> unit
  10. val load        : string -> unit
  11. val loadOne     : string -> unit
  12. val verbose     : bool ref
  13.  
  14. val exnName    : exn -> string
  15. val exnMessage : exn -> string
  16.  
  17. val quotation   : bool ref
  18. val valuepoly   : bool ref
  19.  
  20. val quit        : unit -> 'a
  21. val system      : string -> int
  22.  
  23. (* 
  24.    [printVal e] prints the value of expression e to standard output
  25.    exactly as it would be printed at top-level, and returns the value
  26.    of e.  Output is flushed immediately.  This function is provided as
  27.    a simple debugging aid.  The effect of printVal is similar to that
  28.    of `print' in Edinburgh ML or Umeaa ML.  For string arguments, the 
  29.    effect of SML/NJ print can be achieved by the function 
  30.    TextIO.print : string -> unit.
  31.  
  32.    [printDepth] determines the depth (in terms of nested constructors,
  33.    records, tuples, lists, and vectors) to which values are printed by
  34.    the top-level value printer and the function printVal.  The components
  35.    of the value whose depth is greater than printDepth are printed as
  36.    `#'.  The initial value of printDepth is 20. This value can be
  37.    changed at any moment, by evaluating, for example,
  38.        printDepth := 17;
  39.  
  40.    [printLength] determines the way in which list values are printed
  41.    by the top-level value printer and the function printVal.  If the
  42.    length of a list is greater than printLength, then only the first
  43.    printLength elements are printed, and the remaining elements are
  44.    printed as `...'.  The initial value of printLength is 200.  This
  45.    value can be changed at any moment, by evaluating, for example,
  46.        printLength := 500;
  47.  
  48.    [quit ()] quits Moscow ML immediately.
  49.  
  50.    [installPP pp] installs the prettyprinter pp at type ty, provided
  51.    pp has type ppstream -> ty -> unit.  The type ty must be a nullary
  52.    (parameter-less) type constructor representing a datatype, either
  53.    built-in (such as bool) or user-defined.  Whenever a value of type
  54.    ty is about to be printed by the interactive system, or function
  55.    printVal is invoked on an argument of type ty, the pretty-printer 
  56.    pp will be invoked to print it.  See library unit PP for more
  57.    information.
  58.  
  59.    [use "f"] causes ML declarations to be read from file f as if they
  60.    were entered from the console.  A file loaded by use may, in turn,
  61.    evaluate calls to use.  For best results, use `use' only at top
  62.    level, or at top level within a use'd file.
  63.  
  64.    [compile "U.sig"] will compile and elaborate the unit signature in
  65.    file U.sig, producing a compiled signature file U.ui.  During
  66.    compilation, the compiled signatures of other units will be
  67.    accessed if they are mentioned in U.sig.
  68.  
  69.    [compile "U.sml"] will elaborate and compile the unit body in file
  70.    U.sml, producing a bytecode file U.uo.  If there is an explicit
  71.    signature U.sig, then file U.ui must exist, and the unit body must
  72.    match the signature.  If there is no U.sig, then an inferred
  73.    signature file U.ui will be produced also.  No evaluation takes
  74.    place.  During compilation, the compiled signatures of other units
  75.    will be accessed if they are mentioned in U.sml.
  76.  
  77.    The declared identifiers will be reported if verbose is true (see
  78.    below); otherwise compilation will be silent.  In any case,
  79.    compilation warnings are reported, and compilation errors abort the
  80.    compilation and raise the exception Fail with a string argument.
  81.  
  82.    [load "U"] will load and evaluate the compiled unit body from file
  83.    U.uo.  The resulting values are not reported, but exceptions are
  84.    reported, and cause evaluation and loading to stop.  If U is
  85.    already loaded, then load "U" has no effect.  If any other unit is
  86.    mentioned by U but not yet loaded, then it will be loaded
  87.    automatically before U.
  88.  
  89.    After loading a unit, it can be opened with `open U'.  Opening it
  90.    at top-level will list the identifiers declared in the unit.
  91.  
  92.    When loading U, it is checked that the signatures of units
  93.    mentioned by U agree with the signatures used when compiling U, and
  94.    it is checked that the signature of U has not been modified since U
  95.    was compiled; these checks are necessary for type safety.  The
  96.    exception Fail is raised if these signature checks fail, or if the
  97.    file containing U or a unit mentioned by U does not exist.
  98.  
  99.    [loadOne "U"] is similar to `load "U"', but raises exception Fail
  100.    if U is already loaded or if some unit mentioned by U is not yet
  101.    loaded.  That is, it does not automatically load any units
  102.    mentioned by U.  It performs the same signature checks as `load'.
  103.  
  104.    [verbose] determines whether the signature inferred by a call to
  105.    compile will be printed.  The printed signature follows the syntax
  106.    of Moscow ML signatures, so the output of compile "U.sml" can be
  107.    edited to subsequently create file U.sig.  The default value is
  108.    ref false.
  109.  
  110.    [exnName exn] returns a name for the exception constructor in exn.  
  111.    Never raises an exception itself.  The name returned may be that of
  112.    any exception constructor aliasing with exn.  For instance,
  113.     let exception E1; exception E2 = E1 in exnName E2 end
  114.    may evaluate to "E1" or "E2".
  115.  
  116.    [exnMessage exn] formats and returns a message corresponding to
  117.    exception exn.  For the exceptions defined in the SML Basis Library, 
  118.    the message will include the argument carried by the exception.
  119.  
  120.    [quotation] determines whether quotations and antiquotations are
  121.    permitted in declarations entered at top-level and in files
  122.    compiled with compile.  A quotation is a piece of text surrounded
  123.    by backquote characters `a b c` and is used to embed object
  124.    language phrases in ML programs; see the Moscow ML Owner's Manual
  125.    for a brief explanation of quotations.  When quotation is false,
  126.    the backquote character is an ordinary symbol which can be used in
  127.    ML symbolic identifiers.  When quotation is {\tt true}, the
  128.    backquote character is illegal in symbolic identifiers, and a
  129.    quotation `a b c` will be recognized by the parser and evaluated to
  130.    an object of type 'a General.frag list.  The default value is ref
  131.    false.
  132.  
  133.    [valuepoly] determines whether the type checker should use `value
  134.    polymorphism', making no distinction between imperative ('_a) and
  135.    applicative ('a) type variables, and generalizing type variables
  136.    only in non-expansive expressions.  An expression is non-expansive
  137.    if it is a variable, a special constant, a function, a tuple or 
  138.    record of non-expansive expressions, a parenthesized or typed 
  139.    non-expansive expression, or the application of an exception or value 
  140.    constructor (other than ref) to a non-expansive expression.
  141.     If valuepoly is false, then the type checker will distinguish 
  142.    imperative and applicative type variables, generalize all applicative 
  143.    type variables, and generalize imperative type variables only in
  144.    non-expansive expressions.  This is the default, required by the
  145.    1990 Definition of Standard ML, Section 4.8.
  146.  
  147.    [system "com"] causes the command com to be executed by the
  148.    operating system.  If a non-zero integer is returned, this must
  149.    indicate that the operating system has failed to execute the
  150.    command.  Under MS DOS, the integer returned tends to always equal
  151.    zero, even when the command fails.  
  152. *)
  153.